﻿using System;
using System.Collections.Generic;
using System.Text;
using Task.Common.Interface;
using System.Collections;
using Task.Common.Entity;

namespace Task.Logic
{
    class InboxReadLogic:IInboxRead
    {
        public IList GetList(string where, int start, int limit, out int count)
        {
            Hashtable table = new Hashtable();
            //table.Add("taskid", "05041162c187f3a8e84ba5df1f54be");//参数--条件
            //查询条件的形式 为 [表字段名=参数值; ...]
            if (!String.IsNullOrEmpty(where))
            {
                where = where.TrimEnd(';');//格式化 条件 语句
                string[] strWheres = where.Split(';');//
                for (int i = 0; i < strWheres.Length; i++)
                {
                    string str = strWheres[i];
                    string[] strParems = str.Split('!');
                    table.Add(strParems[0], strParems[1]);//参数 将参数信息添加到hashtable中
                }
            }
            
            IList list = DataHelper.Instance().GetList("InboxReadLogic_GetList", table, start, limit);
            count = list.Count;

            return list;
        }

        public InboxReadEntity Get(string readId)
        {
            return DataHelper.Instance().Get<InboxReadEntity>("TaskLogic_Get", readId);
        }

        public void Insert(InboxReadEntity entity)
        {
            DataHelper.Instance().Insert("TaskLogic_Insert", entity);
        }

        public void Update(InboxReadEntity entity)
        {
            DataHelper.Instance().Update("TaskLogic_Update", entity);
        }

        public bool Exists(string taskId)
        {
            throw new NotImplementedException();
        }

        public void Delete(string taskId)
        {
            DataHelper.Instance().Delete("TaskLogic_Delete", taskId);
        }


        public IList GetListFin(string where, int start, int limit, out int count)
        {
            Hashtable table = new Hashtable();
            //table.Add("taskid", "05041162c187f3a8e84ba5df1f54be");//参数--条件
            //查询条件的形式 为 [表字段名=参数值; ...]
            if (!String.IsNullOrEmpty(where))
            {
                where = where.TrimEnd(';');//格式化 条件 语句
                string[] strWheres = where.Split(';');//
                for (int i = 0; i < strWheres.Length; i++)
                {
                    string str = strWheres[i];
                    string[] strParems = str.Split('!');
                    table.Add(strParems[0], strParems[1]);//参数 将参数信息添加到hashtable中
                }
            }

            IList list = DataHelper.Instance().GetList("FinishedReadLogic_GetList", table, start, limit);
            count = list.Count;

            return list;
        }


        public void Update(Hashtable hs)
        {
            DataHelper.Instance().Update("UpdateFinReadStatus", hs);
        }
    }
}
